package com.hy.controller;


import com.hy.pojo.Hospital;
import com.hy.pojo.Province;
import com.hy.service.IHospitalService;
import com.hy.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2025-03-05
 */
@RestController
@RequestMapping("/hospital")
public class HospitalController {
    @Autowired
    private IHospitalService hospitalService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PostMapping("/list")
    public QueryPageResult list(@RequestBody QueryPageBean queryPageBean){
        return hospitalService.selectHospitalList(queryPageBean);
    }

    @RequestMapping("/findHospitals")
    public Result findHospitals(){
        List<Hospital> list = hospitalService.findHospitals();
        return Result.success( "查询成功", list);
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id) {
        return Result.success(hospitalService.selectHospitalById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PostMapping
    public Result add(@RequestBody Hospital hospital){
        return Result.success(hospitalService.insertHospital(hospital));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PutMapping
    public Result edit(@RequestBody Hospital hospital) {
        return Result.success(hospitalService.updateHospital(hospital));
    }

    @RequestMapping("/upload")
    public Result fileUploadService(@RequestParam("file") MultipartFile file) throws Exception {
        String fileUrl=hospitalService.updatefile(file);
        return new Result(200,"上传成功",fileUrl) ;
    }

    /**
     * 删除【请填写功能名称】
     */
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids) {
        return Result.success(hospitalService.deleteHospitalByIds(ids));
    }

    @RequestMapping("/findDepByHospitalId")
    public QueryPageResult findDepByHospitalId(@RequestBody QueryPageBean queryPageBean){
        return hospitalService.findDepByHospitalId(queryPageBean);
    }

    @RequestMapping("/findDocByHospitalId")
    public QueryPageResult findDocByHospitalId(@RequestBody QueryPageBean queryPageBean){
        return hospitalService.findDocByHospitalId(queryPageBean);
    }
}
